﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutBase.cshtml";
}
@model IEnumerable<RTW.OA.Models.diary>
@section styles{
    <link href="@Url.Content("~/Content/css/ace/ace.min.css")" rel="stylesheet" />
    <link href="@Url.Content("~/Content/css/ace/ace-rtl.min.css")" rel="stylesheet" />
    <link href="@Url.Content("~/Content/css/ace/ace-skins.min.css")" rel="stylesheet" />
    @*<link href="@Url.Content("~/Content/css/ace/font-awesome.min.css")" rel="stylesheet" />*@
    <style type="text/css">
        .content-ellipsis {
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 3;
        }
    </style>
}

<div class="col-md-3">
    <div class="widget-box">
        <div style="margin-bottom:5px;">@Html.Editor("querydate", new { htmlAttributes = new { @Class = "input rule-date-input form-control", onfocus = "WdatePicker({ dateFmt: 'yyyy-MM-dd'})", placeholder = "发布日期" } })</div>
        <div class="widget-header">
            <h3 class="lighter smaller">在职人员</h3>
        </div>

        <div class="widget-body">
            <div class="widget-main padding-8">
                <div id="tree2" class="tree"></div>
            </div>
        </div>
    </div>
</div>
<div class="col-md-9">
    <div class="widget-box">
        <div class="widget-header">
            <h3 class="lighter smaller">日志列表</h3>
        </div>

        <div class="widget-body">
            <div class="widget-main padding-8">
                <div id="diary_init_list">
                    @foreach (var item in Model)
                    {
                        <div class="ibox">
                            <div class="ibox-content">
                                <div class="one_diary">
                                    <h3><a onclick="parent.createTab('0803','日志明细','@Url.Action("Details", "Diary", new { area = "Personal" })/@item.DIA_ID')">@item.SUBJECT</a></h3>
                                    <hr />
                                    <div class="diary_type">工作日志 | 日志日期：@item.DIA_TIME</div>
                                    <br />
                                    <div class="content content-ellipsis">
                                        <p>@Html.Raw(item.CONTENT)</p>
                                    </div>
                                    <br />
                                    <div class="diary_foot">
                                        <div class="row">
                                            <div class="col-md-6">
                                            </div>
                                            <div class="col-md-6">
                                                <div class="small text-right">
                                                    <h5>状态：</h5>
                                                    <div><a onclick="parent.createTab('0803','日志明细','@Url.Action("Details","Diary",new { area="Personal"})/@item.DIA_ID#comment')">@item.diary_comments.Count 评论 </a></div>
                                                    <i class="fa fa-eye"> </i> @item.READERS 浏览
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    }
                </div>
                <div id="diary_list">
                    <div v-if="diarys.length > 0">
                        <div v-for="item in diarys">
                            <diary-item v-bind:diary="item"></diary-item>
                        </div>
                    </div>
                    <div v-else>
                        <h5 class="text-center" style="color:gray;">列表暂无数据</h5>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<template id="diary_template">
    <div class="ibox">
        <div class="ibox-content">
            <div class="one_diary">
                <h3><a @@click="parent.createTab('0803','日志明细','/Personal/Diary/Details/'+diary.DIA_ID)">{{diary.SUBJECT}}</a></h3>
                <hr />
                <div class="diary_type">工作日志 | 日志日期：{{diary.DIA_TIME|dateFormat}}</div>
                <br />
                <div class="content content-ellipsis" v-html="diary.CONTENT"></div>
                <br />
                <div class="diary_foot">
                    <div class="row">
                        <div class="col-md-6">
                        </div>
                        <div class="col-md-6">
                            <div class="small text-right">
                                <h5>状态：</h5>
                                <div><a @@click="parent.createTab('0803','日志明细','/Personal/Diary/Details/'+diary.DIA_ID+'#comment')">{{diary.diary_comments.length}} 评论 </a></div>
                                <i class="fa fa-eye"> </i> {{diary.READERS}} 浏览
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

@section scripts{
    <script src="@Url.Content("~/Content/JS/common/WdatePicker/WdatePicker.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/jquery/Validform_v5.3.2_min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/artdialog/dialog-plus-min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/webuploader/webuploader.min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/ueditor.config.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/ueditor.all.min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/lang/zh-cn/zh-cn.js")"></script>
    @*<script type="text/javascript" charset="utf-8" src="../js/uploader.js"></script>*@

    <script src="@Url.Content("~/Content/JS/common/from.js")"></script>
    <script src="@Url.Content("~/Content/js/ace/typeahead-bs2.min.js")"></script>
    <script src="@Url.Content("~/Content/js/ace/fuelux.tree-sampledata.js")"></script>
    <script src="@Url.Content("~/Content/js/ace/fuelux.tree.min.js")"></script>
    <script src="@Url.Content("~/Content/js/ace/ace.min.js")"></script>
    <script src="@Url.Content("~/Content/js/ace/ace-elements.min.js")"></script>
    <script src="@Url.Content("~/Content/js/ace/ace-extra.min.js")"></script>
    <script src="@Url.Content("~/Content/js/vue.min.js")"></script>
    <script src="@Url.Content("~/Content/js/common/Date.js")"></script>
    <script type="text/javascript">
        Vue.filter("dateFormat", function (value) {
            var date = new Date(parseInt(value.substr(6, 13)));
            return date.Format("yyyy-MM-dd hh:mm:ss");
        });

        var vo = new Vue({
            el: '#diary_list',
            components: {
                'diary-item': {
                    props: ["diary"],
                    template: '#diary_template'
                }
            },
            data: {
                diarys: []
            }
        });

        var tree_data_4 = {
        @foreach (var item in ViewBag.depts)
        {
            <text>
                    'department@(item.DEPT_ID)':
            {
                name: '<span class="icon-music blue" onclick="getSearchData(1,@item.DEPT_ID);">@item.DEPT_NAME</span>', type: 'folder', 'icon-class': 'blue'
            },
            </text>
        }
        }

        @foreach (var item in ViewBag.depts)
        {
            <text>
            tree_data_4['department@(item.DEPT_ID)']['additionalParameters'] = {
            'children': [
                        @foreach (var user in item.users) {
                            <text>
                { name: '<span class="icon-music blue" onclick="getSearchData(2,@user.USER_ID);">@user.TRUE_NAME</span>', type: 'item' },
                            </text>
                        }
                    ]
            }
            </text>
        }

        var getSearchData = function (type, id) {
            $.get("GetDiarySearch?type=" + type + "&id=" + id + "&querydate=" + $("#querydate").val(), function (result) {
                if (result.code == "100") {
                    $("#diary_init_list").html("");
                    vo.diarys = [];
                    result.data.forEach(function (item) {
                        vo.diarys.push(item);
                    });
                }
            });
        }

        jQuery(function ($) {
            $('#tree2').ace_tree({
            dataSource: new DataSourceTree({ data: tree_data_4 }),
                loadingHTML: '<div class="tree-loading"><i class="icon-refresh icon-spin blue"></i></div>',
                'open-icon': 'icon-folder-open',
                'close-icon': 'icon-folder-close',
                'selectable': false,
                'selected-icon': null,
                'unselected-icon': null
            });
        });
    </script>
}
